package Lesson4;

import java.util.Scanner;

public class Task9 {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		
		System.out.println("Enter number \"a\" ");
		int a = sc.nextInt();
		System.out.println("Enter a number d ");
		int b = sc.nextInt();
		
		int[][] m = new int [4][4];
		
		int d = 3;
		int r = 3;
		int u = 0;
		int L = 0;
		
		for(int i = 1; i<d-1; i++)
		{
			for(int j = 1; j < r ; j++)
			{
				m[i][j] = a;
				a +=b;
			}
		}
		for(int i = d-1; i > u+1 ; i--)
		{
			for (int j = r-1; j >= L; j--)
			{
				m[i][j] = a;
				a+=b;
			}
		}
		for(int i = d-2; i >= u; i--)
		{
			for(int j = L; j == L; j++)
			{
				m[i][j] = a;
				a +=b;
			}
		}
		for(int i = u; i==u; i++)
		{
			for(int j = L+1 ; j <= r; j++)
			{
				m[i][j] = a;
				a +=b;
			}
		}
		
		for (int i = u+1; i<=d; i++)
		{
			for (int j = r; j == r ; j++)
			{
				m[i][j] = a;
				a +=b;
			}
		}
				
		for(int i = d; i == d; i--)
		{
			for(int j = r-1; j >= L; j--)
			{
				m[i][j] = a;
				a += b;
			}
		}
		
		for( int i = 0; i < 4; i++ )
		{
			for(int j = 0; j<m[i].length; j++)
			{
				System.out.print(m[i][j] + " ");
			}
			System.out.println();
		}
		
		
		
		
	}

}
